import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// ...
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
       }),
      Components({
      resolvers: [ElementPlusResolver()],
       })
  ],
  resolve: {
    alias: {  //@符号对应的是别名，对src做了一个绝对路径，@代表src的绝对路径
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },        //代理规则的配置
  server: {
    proxy: {
      "/dev-api": {
    target: "http://127.0.0.1:19090/system",
    rewrite: (p) => p.replace(/^\/dev-api/, ""),
       },
     },  
   },
})
//http://localhost:5173/dev-api/sysUser/login  当配置代理规则之后，一旦我们请求是包含 dev-api时候，会把请求转发给target
//会有一个rewrite,用户吧devapi变成空字符串， 相当于替换了前面，然后吧哪个dev-api去掉

